<?php
/**
+-----------------------------------------------------------------------+
* @autor tonera <tonera at gmail.com>;
* @since 2007-9-24
* @version $Id: update_1.3.3_1.3.4.php,v 1.3.6 tonera$
* @description	此升级程序主要是升级数据库.仅用于1.3.5升级到1.3.6
+-----------------------------------------------------------------------+
*/
error_reporting(0);
include_once(dirname(__FILE__) . "/php/config.inc.php");
include_once(CHINO_PATH . "/Chino.php");
include_once CHINO_MODPATH.'/config/config.inc.php';
include_once CHINO_PHPPATH.'/lang/lang_public.php';

$GLOBALS['adodb'] = Chino::getObject('adodb');
$GLOBALS['adodb']->debug	= false;
$wow_cfg_lang	= empty($_COOKIE['wow_cfg_lang'])?"zh-cn":$_COOKIE['wow_cfg_lang'];
if(!array_key_exists($wow_cfg_lang, $langTypeArray)) $wow_cfg_lang='zh-cn';
include_once(CHINO_PHPPATH .  "/lang/".$wow_cfg_lang."/inslang.inc.php");


$sql	= array();
$sql[]	= "CREATE TABLE ".TABLEHEAD."_syslog (id int(11) NOT NULL auto_increment,uid int(11) default NULL,uname varchar(100) NOT NULL default '',op varchar(50) default NULL,obj varchar(255) default NULL,des varchar(255) default NULL,optime int(11) NOT NULL default '0', PRIMARY KEY  (id)) TYPE=MyISAM AUTO_INCREMENT=1 ;";
foreach($racename as $key=>$val) {
	if($key == 8 or $key == 9)
	{
		$sql[]	= "insert into ".TABLEHEAD."_race(name) values('$val')";
	}
}

$link	= $GLOBALS['adodb']->connect(DBHOST, DBUSER, DBPASS, DBNAME);
if(!$link) {
	echo("Error:can't connect database.");
	exit;
}

$ismysql5		= false;
$mysqlvrs		= $GLOBALS['adodb']->execute("select version()");
$mysqlversion	= $mysqlvrs->fields[0];
if($mysqlversion > '4.1') {
	$ismysql5	= true;
	$GLOBALS['adodb']->execute("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
	if($mysqlversion > '5.0.1') {
		$GLOBALS['adodb']->execute("SET sql_mode=''");
	}
}


foreach($sql as $key=>$val) {
	if($ismysql5) {
		$val	= preg_replace("/TYPE=MyISAM/i","TYPE=MyISAM DEFAULT CHARSET=utf8 ",$val);
	}
	$rs	= $GLOBALS['adodb']->execute($val);
}

if(!$rs) {
	echo("Error: can't update.");
}else {
	echo("OK! Please delete the file.");
}



?>